<html>
<head><meta charset="utf-8"><title>summarizing for lang team · project-safe-transmute · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/index.html">project-safe-transmute</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html">summarizing for lang team</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="215124970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215124970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215124970">(Oct 30 2020 at 17:20)</a>:</h4>
<p>Hey do you think somebody from this group could post a quick update to <a href="https://github.com/rust-lang/lang-team/issues/21">https://github.com/rust-lang/lang-team/issues/21</a> to give a status update on the discussions around the rfc? (cc <span class="user-mention" data-user-id="219211">@Jack Wrenn</span> <span class="user-mention" data-user-id="224872">@Ryan Levick</span> or <span class="user-mention" data-user-id="239881">@Josh Triplett</span> ). Sometime before monday triage would be awesome</p>



<a name="215125249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215125249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215125249">(Oct 30 2020 at 17:22)</a>:</h4>
<p><span class="user-mention" data-user-id="219211">@Jack Wrenn</span> when do you expect your latest revision to be available for others to view? I think the RFC is reaching a great place after the back-and-forth with Boats and Ralf. I'm happy to write the summary if it helps you focus on the RFC proper.</p>



<a name="215125521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215125521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215125521">(Oct 30 2020 at 17:24)</a>:</h4>
<p>I'll have the latest revision done within the next hour!</p>



<a name="215125755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215125755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215125755">(Oct 30 2020 at 17:26)</a>:</h4>
<p>Would you like to write the summary for the issue or do you want me to?</p>



<a name="215126111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215126111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215126111">(Oct 30 2020 at 17:29)</a>:</h4>
<p>Could you take a stab at it?</p>



<a name="215126134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215126134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215126134">(Oct 30 2020 at 17:29)</a>:</h4>
<p>(I can definitely pitch in when free moments arise, and confirm that it's accurate.)</p>



<a name="215155841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215155841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215155841">(Oct 30 2020 at 22:01)</a>:</h4>
<p>I’ll get it to you very first thing Monday morning</p>



<a name="215301383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215301383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215301383">(Nov 02 2020 at 10:30)</a>:</h4>
<p>I've added an update: <a href="https://github.com/rust-lang/lang-team/issues/21#issuecomment-720384232">https://github.com/rust-lang/lang-team/issues/21#issuecomment-720384232</a>. Let me know if you something should be added, removed, corrected, etc.</p>



<a name="215371767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215371767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215371767">(Nov 02 2020 at 20:10)</a>:</h4>
<p>Thanks for the update!  A question I had: does losing <code>Here!</code> also imply that the <code>transmute!</code> macro interface is going away?  (I'd had a bunch of interface comments queued up about trait layout given the macro...)</p>



<a name="215372021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215372021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215372021">(Nov 02 2020 at 20:13)</a>:</h4>
<p><code>transmute!</code> is still there! We <em>could</em> ditch it though, since it mostly existed to improve the ergonomics of <code>Here!()</code>.</p>



<a name="215372470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215372470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215372470">(Nov 02 2020 at 20:17)</a>:</h4>
<p>Writing <code>transmute!()</code> is certainly a lot shorter than <code>TransmuteFrom::&lt;_, _,&gt;::transmute_from</code>, but the issue <em>has</em> been raised a few times (first with <code>TransmuteInto</code>) that perhaps transmutation <em>shouldn't</em> be ergonomic.</p>



<a name="215372647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215372647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215372647">(Nov 02 2020 at 20:18)</a>:</h4>
<p>I think we do want the <em>safe</em> one to be more ergonomic than <code>unsafe { mem::transmute(foo) }</code>.</p>
<p>(I don't know what that ends up meaning in the end, though.)</p>



<a name="215372895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215372895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215372895">(Nov 02 2020 at 20:20)</a>:</h4>
<p>We say that right now you <em>shouldn't</em> do that, saying it should always be <code>unsafe { mem::transmute::&lt;Foo, Bar&gt;(foo) }</code>, but we don't force that in any way AFAIK.  (Maybe clippy does?)</p>



<a name="215373138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215373138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215373138">(Nov 02 2020 at 20:22)</a>:</h4>
<p>I don't use clippy much since RA doesn't support it well, but when I did use clippy I don't remember it ever telling me to make transmute more explicit in the types.</p>



<a name="215374190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215374190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215374190">(Nov 02 2020 at 20:30)</a>:</h4>
<p>(I just <a href="https://rust-lang.github.io/rust-clippy/master/index.html">checked</a>; it looks like you're right.  There are some specific cases, but nothing about turbofishing.)</p>



<a name="215376876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215376876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215376876">(Nov 02 2020 at 20:51)</a>:</h4>
<p>When this RFC had <code>transmute_into</code>, <em>that</em> was maybe even more ergonomic:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">bar</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">foo</span><span class="p">.</span><span class="n">transmute_into</span><span class="p">();</span><span class="w"></span>
</code></pre></div>



<a name="215379627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215379627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215379627">(Nov 02 2020 at 21:13)</a>:</h4>
<p><span class="user-mention silent" data-user-id="219211">Jack Wrenn</span> <a href="#narrow/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team/near/215372470">said</a>:</p>
<blockquote>
<p>Writing <code>transmute!()</code> is certainly a lot shorter than <code>TransmuteFrom::&lt;_, _,&gt;::transmute_from</code></p>
</blockquote>
<p>Wouldn't you often write <code>ConcreteType::transmute_from</code>?</p>



<a name="215379743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215379743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215379743">(Nov 02 2020 at 21:14)</a>:</h4>
<p>(Also, yes, I'd love to have <code>transmute_into</code>, and I expect that if it isn't available in the RFC people will invent it. What was the rationale for removing it, again?)</p>



<a name="215379781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215379781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215379781">(Nov 02 2020 at 21:15)</a>:</h4>
<p>Yep, that's a fair point. <code>transmute!()</code> maybe isn't a huge win over <code>ConcreteType::transmute_from</code>.</p>



<a name="215379943"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215379943" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215379943">(Nov 02 2020 at 21:16)</a>:</h4>
<p>Also, in cases where you have enough information for type inference, you <em>could</em> just write <code>TransmuteFrom::transmute_from</code>, and we've talked about being able to write things like <code>use Default::default</code> which would cover this case as well.</p>



<a name="215380041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215380041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215380041">(Nov 02 2020 at 21:17)</a>:</h4>
<p>Or, in the interim, we could provide a free function <code>fn transmute_from</code> that calls <code>TransmuteFrom::transmute_from</code>.</p>



<a name="215380077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215380077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215380077">(Nov 02 2020 at 21:17)</a>:</h4>
<p>Though I <em>do</em> think it's still really handy to be able to append <code>.transmute_into()</code>.</p>



<a name="215380110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215380110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215380110">(Nov 02 2020 at 21:17)</a>:</h4>
<p>Given all of the above, I <em>do</em> think we should drop the <code>transmute!</code> macro in favor of functions.</p>



<a name="215380600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215380600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215380600">(Nov 02 2020 at 21:21)</a>:</h4>
<p>Chiefly, because the RFC was getting long, it was <em>solely</em> an ergonomic nicety, and keeping <code>TransmuteInto</code> updated with changes to the RFC was just adding labor; it'd be easy to add back on once the dust settles.</p>
<p>That said, I've also had a niggling worry about what people write on <code>where</code> bounds. If a function has a where bound with <code>TransmuteFrom</code>, you need to repeat <em>that</em> <code>where</code> bound in any generic context that invokes that function—<em>not</em> <code>TransmuteInto</code>.</p>
<p>If people are writing both <code>TransmuteFrom</code> and <code>TransmuteInto</code> in various places, I'm concerned about creating a situation where someone has to write something truly silly like:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">Foo</span>: <span class="nc">TransmuteFrom</span><span class="o">&lt;</span><span class="n">Bar</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">Bar</span>: <span class="nc">TransmuteInto</span><span class="o">&lt;</span><span class="n">Foo</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
</code></pre></div>



<a name="215381723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215381723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215381723">(Nov 02 2020 at 21:30)</a>:</h4>
<p>We could have a sealed <code>TransmuteInto</code> trait with a single blanket impl.</p>



<a name="215381917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215381917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215381917">(Nov 02 2020 at 21:32)</a>:</h4>
<p>Is the compiler always smart enough to understand that <code>TransmuteFrom</code> and <code>TransmuteInto</code> imply each other? I wasn't sure of this.</p>



<a name="215381995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215381995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215381995">(Nov 02 2020 at 21:32)</a>:</h4>
<p>I'm not sure either.</p>



<a name="215382019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215382019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215382019">(Nov 02 2020 at 21:33)</a>:</h4>
<p>This is why I'm definitely going to keep running <code>bytemuck</code> after this all lands. Hard to beat the elegance of <code>cast(val)</code></p>



<a name="215382022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215382022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215382022">(Nov 02 2020 at 21:33)</a>:</h4>
<p>It <em>should</em> be smart enough to do that in one direction, always.</p>



<a name="215382054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215382054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215382054">(Nov 02 2020 at 21:33)</a>:</h4>
<p>I don't know if it's smart enough to go backwards.</p>



<a name="215382082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215382082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215382082">(Nov 02 2020 at 21:33)</a>:</h4>
<p>In any case, adding <code>TransmuteInto</code> seems like it can happen after we finalize the RFC.</p>



<a name="215382094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215382094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215382094">(Nov 02 2020 at 21:33)</a>:</h4>
<p><code>TransmuteFrom::transmute_from</code> isn't bad.</p>



<a name="215382107"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215382107" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215382107">(Nov 02 2020 at 21:33)</a>:</h4>
<p>And a free function <code>transmute_from</code> would be even better.</p>



<a name="215382168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215382168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215382168">(Nov 02 2020 at 21:34)</a>:</h4>
<p><span class="user-mention silent" data-user-id="219211">Jack Wrenn</span> <a href="#narrow/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team/near/215381917">said</a>:</p>
<blockquote>
<p>Is the compiler always smart enough to understand that <code>TransmuteFrom</code> and <code>TransmuteInto</code> imply each other? I wasn't sure of this.</p>
</blockquote>
<p>I'd been meaning to comment about this, actually.</p>
<p>I was wondering whether all these traits should be empty so that they could in the future be made <code>#[marker]</code> traits.</p>
<p>Which would imply we'd want a free function or macro or extension trait or something to be the ergonomic option.</p>



<a name="215382274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215382274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215382274">(Nov 02 2020 at 21:35)</a>:</h4>
<p>Alternatively, it could be a reason to revisit the "marker traits can have associated items, just not override them".</p>
<p>There's another side to that of "would it ever be sane for someone to override one of these methods"?  It feels like no...</p>



<a name="215383383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215383383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215383383">(Nov 02 2020 at 21:44)</a>:</h4>
<p>Hard to imagine any scenario where you'd override <code>transmute_from</code>, yeah.</p>



<a name="215383692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215383692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215383692">(Nov 02 2020 at 21:47)</a>:</h4>
<p><span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span> for making them marker traits.</p>



<a name="215385813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215385813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215385813">(Nov 02 2020 at 22:05)</a>:</h4>
<p>"Out there" idea: the free function is just <code>mem::transmute</code>, which is unsafe if the trait bound isn't met.</p>
<p>(It's already special, as an intrinsic export, so it's not completely implausible.  That said, it can't be turned into a function pointer today because it's magic, and <code>.map(safe_transmute_thing)</code> would be a reasonable thing to do with the safe version, so maybe that's enough of a reason to consider it a bad idea -- atop the "conditional unsafety is too magic" ones.)</p>



<a name="215385905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215385905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215385905">(Nov 02 2020 at 22:06)</a>:</h4>
<p>I would rather <em>not</em> have <code>transmute</code> be safe/unsafe depending on a marker trait.</p>



<a name="215385923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215385923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215385923">(Nov 02 2020 at 22:07)</a>:</h4>
<p>Because even in an unsafe block, I'd like to know if I'm invoking a safe or unsafe transmute.</p>



<a name="215386113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215386113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215386113">(Nov 02 2020 at 22:09)</a>:</h4>
<p>A perk of <code>TransmuteFrom</code> having a <code>transmute_from</code> method is that, as <span class="user-mention" data-user-id="239881">@Josh Triplett</span> points out, you often just write <code>ConcreteType:transmute_from</code>, which makes the destination type explicit. This is in contrast to <code>mem::transmute</code>, where the most natural thing to do is to elide the turbofish.</p>



<a name="215386516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215386516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215386516">(Nov 02 2020 at 22:12)</a>:</h4>
<p>With a free function you end up writing it<br>
<code>let bar: BarType = transmute(foo);</code><br>
And as an associated function you end up writing<br>
<code>let bar = BarType::transmute_from(foo);</code><br>
So it's basically all the same anyway.</p>



<a name="215386648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215386648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Quy Nguyen <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215386648">(Nov 02 2020 at 22:13)</a>:</h4>
<p>You could also just have an extension trait with a blanket impl and love the current one a marker.</p>



<a name="215386725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215386725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215386725">(Nov 02 2020 at 22:14)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span>  What's the advantage of a free function, as opposed to a method?</p>



<a name="215393504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/summarizing%20for%20lang%20team/near/215393504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/summarizing.20for.20lang.20team.html#215393504">(Nov 02 2020 at 23:33)</a>:</h4>
<p>FWIW, there is also the option of non-elidable turbofish: <code>&lt;expr&gt;.transmute_into::&lt;ConcreteType&gt;()</code>. It's worse than <code>ConcreteType::transmute_from(&lt;expr&gt;)</code> <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span>  but has the advantage of playing better with method chains.<br>
To get non-elidable turbofish, you add a new param, say <code>U</code> with the bound <code>U : Is&lt;EqTo = T&gt;</code>, where:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">trait</span><span class="w"> </span><span class="n">Is</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">type</span> <span class="nc">EqTo</span><span class="w"> </span>: <span class="o">?</span><span class="nb">Sized</span><span class="p">;</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="w"> </span>: <span class="o">?</span><span class="nb">Sized</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Is</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">type</span> <span class="nc">EqTo</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">Self</span><span class="p">;</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</code></pre></div>
<ul>
<li><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=1185614d08f4dbc6adac0e0406cc960c">Demo</a></li>
</ul>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>